#!/usr/bin/env python

import resource.string.app

from .._console import Console

class Inspector(Console):
    
    def run(self):
        self.greeting(resource.string.app)
        
        modem = self.loadModem()
        if modem: self.inspect(modem)
        
        self.farewell()

    def loadModem(self):
        self.progress('Opening modem... ')
        modem = super(Inspector, self).loadModem()
        if modem: self.success('OK ^_^v\n')
        else: self.fail('Error >_<\n') 
        return modem
    
    def inspect(self, modem):
        self.progress('Inspecting Message Storage... ')
        results = modem.cpms('?')
        if results:
            self.success('OK ^_^v\n')
            self.info('Available storage:\n')
            for result in results:
                self.info('- %s\n' % result)
        else: self.fail('Error >_<\n')
        